
#include "stdafx.h"
#include "WicPixelFormatInfo.h"

//==============================================================================
// CWicPixelFormatInfo
//==============================================================================
CWicPixelFormatInfo::CWicPixelFormatInfo(CWicComponentInfo *pComponentInfo)
{
    m_pIWICPixelFormatInfo = NULL;
    g_hrLast = pComponentInfo->m_pIWICComponentInfo->QueryInterface(
        IID_IWICPixelFormatInfo, (void**)&m_pIWICPixelFormatInfo);
}

CWicPixelFormatInfo::~CWicPixelFormatInfo()
{
    if(m_pIWICPixelFormatInfo)
    {
        m_pIWICPixelFormatInfo->Release();
    }
    m_pIWICPixelFormatInfo = NULL;
}

CWicPixelFormatInfo::CWicPixelFormatInfo(CWicPixelFormatInfo const & objPixelFormatInfo)
{
    m_pIWICPixelFormatInfo = objPixelFormatInfo.m_pIWICPixelFormatInfo;
    m_pIWICPixelFormatInfo->AddRef();
}

CWicPixelFormatInfo& CWicPixelFormatInfo::operator=(CWicPixelFormatInfo const & objPixelFormatInfo)
{
    if(m_pIWICPixelFormatInfo)
    {
        m_pIWICPixelFormatInfo->Release();
    }
    m_pIWICPixelFormatInfo = objPixelFormatInfo.m_pIWICPixelFormatInfo;
    m_pIWICPixelFormatInfo->AddRef();
    return *this;
}

//==============================================================================
// IWICComponentInfo
//==============================================================================
HRESULT CWicPixelFormatInfo::GetFormatGUID(/* [out] */ GUID *pFormat)
{
    g_hrLast = m_pIWICPixelFormatInfo->GetFormatGUID(pFormat);
    return g_hrLast;
}

HRESULT CWicPixelFormatInfo::GetColorContext(/* [out] */ IWICColorContext **ppIColorContext)
{
    g_hrLast = m_pIWICPixelFormatInfo->GetColorContext(ppIColorContext);
    return g_hrLast;
}

HRESULT CWicPixelFormatInfo::GetBitsPerPixel(/* [out] */ UINT *puiBitsPerPixel)
{
    g_hrLast = m_pIWICPixelFormatInfo->GetBitsPerPixel(puiBitsPerPixel);
    return g_hrLast;
}

HRESULT CWicPixelFormatInfo::GetChannelCount(/* [out] */ UINT *puiChannelCount)
{
    g_hrLast = m_pIWICPixelFormatInfo->GetChannelCount(puiChannelCount);
    return g_hrLast;
}

HRESULT CWicPixelFormatInfo::GetChannelMask(
                       /* [in] */ UINT uiChannelIndex,
                       /* [in] */ UINT cbMaskBuffer,
                       /* [size_is][unique][out][in] */ BYTE *pbMaskBuffer,
                       /* [out] */ UINT *pcbActual)
{
    g_hrLast = m_pIWICPixelFormatInfo->GetChannelMask(uiChannelIndex, cbMaskBuffer, pbMaskBuffer, pcbActual);
    return g_hrLast;
}

//==============================================================================
// IWICComponentInfo
//==============================================================================
WICComponentType CWicPixelFormatInfo::GetComponentType()
{
    WICComponentType type;
    g_hrLast = m_pIWICPixelFormatInfo->GetComponentType(&type);
    return type;
}

HRESULT CWicPixelFormatInfo::GetCLSID(/* [out] */ CLSID *pclsid)
{
    g_hrLast = m_pIWICPixelFormatInfo->GetCLSID(pclsid);
    return g_hrLast;
}

DWORD CWicPixelFormatInfo::GetSigningStatus()
{
    DWORD dwStatus = 0;
    g_hrLast = m_pIWICPixelFormatInfo->GetSigningStatus(&dwStatus);
    return dwStatus;
}

UINT CWicPixelFormatInfo::GetAuthor(UINT cchAuthor, WCHAR *wzAuthor)
{
    UINT uResult = 0;
    g_hrLast = m_pIWICPixelFormatInfo->GetAuthor(cchAuthor, wzAuthor, &uResult);
    return uResult;
}

HRESULT CWicPixelFormatInfo::GetVendorGUID(/* [out] */ GUID *pguidVendor)
{
    g_hrLast = m_pIWICPixelFormatInfo->GetVendorGUID(pguidVendor);
    return g_hrLast;
}

UINT CWicPixelFormatInfo::GetVersion(UINT cchVersion, WCHAR *wzVersion)
{
    UINT uResult = 0;
    g_hrLast = m_pIWICPixelFormatInfo->GetVersion(cchVersion, wzVersion, &uResult);
    return uResult;
}

UINT CWicPixelFormatInfo::GetSpecVersion(UINT cchSpecVersion, WCHAR *wzSpecVersion)
{
    UINT uResult = 0;
    g_hrLast = m_pIWICPixelFormatInfo->GetSpecVersion(cchSpecVersion, wzSpecVersion, &uResult);
    return uResult;
}

UINT CWicPixelFormatInfo::GetFriendlyName(UINT cchFriendlyName, WCHAR *wzFriendlyName)
{
    UINT uResult = 0;
    g_hrLast = m_pIWICPixelFormatInfo->GetFriendlyName(cchFriendlyName, wzFriendlyName, &uResult);
    return uResult;
}

